package com.zjnx.train.util;

public class Gender implements Enumx {

	private String value;

	// 私有构造器保证枚举定义规范
	private Gender(String value) {
		this.value = value;
	}

	public static final Gender MALE = new Gender("male");
	public static final Gender FEMALE = new Gender("female");
	public static final Gender OTHER = new Gender("other");
	public static final Gender[] ALL = { MALE, FEMALE, OTHER };

	@Override
	public String getValue() {
		return value;
	}

	@Override
	public String toString() {
		return this.getValue();
	}

	@Override
	public Gender instance(String value) {
		for (int i = 0; i < ALL.length; i++) {
			Gender foo = ALL[i];
			if (foo.getValue().equals(value))
				return foo;
		}
		return null;
	}

}
